﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;

namespace App.Views.CheckoutService
{
    //打印公司收入报表
    public partial class IncomeIndex : System.Web.Mvc.ViewPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Views/FeeQueryService/rptIncomeSummary.rdlc");
                ReportDataSource datasource = new ReportDataSource();
                datasource.Name = "dsIncomeSummary";
                string starttime = Request.QueryString["StartTime"];
                string endtime = Request.QueryString["EndTime"];
                DateTime st = DateTime.MinValue;
                DateTime et = DateTime.MaxValue;
                try
                {
                    st = DateTime.Parse(starttime);
                }
                catch
                {
                    st = DateTime.MinValue;
                }
                try
                {
                    et = DateTime.Parse(endtime);
                    et = et.AddDays(1);
                }
                catch
                {
                    et = DateTime.MaxValue;
                }
                datasource.Value = App.Models.ReportClass.GetFeesSummaryByTimeSpan(st, et);
                ReportParameter[] parameters = new ReportParameter[2];
                parameters[0] = new ReportParameter("starttime", starttime);
                parameters[1] = new ReportParameter("endtime", endtime);
                ReportViewer1.LocalReport.SetParameters(parameters);
                ReportViewer1.LocalReport.DataSources.Add(datasource);
            } 
        }
    }
}